{% extends "base.html" %}

{% block title %}{{ block.super }} &bull; Useragent Results Comparison{% endblock %}

{% block content %}

<h2>Useragent Results Comparison</h2>

<a href=".">reset query</a>

<form action="." method="GET">
{{ form.as_p }}
<input type="submit" value="Compare" />

{% if form.is_valid %}

{% regroup results|dictsort:"kind" by kind as result_list %}

<h2>Summary</h2>
<dl>
    {% for kind in result_list %}
        <dt><a href="#{{ kind.grouper|slugify }}">{{ kind.grouper }}</a></dt>
        <dd>{{ kind.list|length }}</dd>
    {% endfor %}
    <dt>Results unique in {{ to_ua }}</dt>
    <dd>{{ unique_to_count }}</dd>
    <dt>Results unique in {{ from_ua }}</dt>
    <dd>{{ unique_from_count }}</dd>
</dl>

{% for kind in result_list %}
    <h2 id="{{ kind.grouper|slugify }}">{{ kind.grouper }}</h2>
    <table class="tests-table">
        <thead>
            <th><a href="{{ from_ua.get_absolute_url}}">{{ from_ua }}</a></th>
            <th><a href="{{ to_ua.get_absolute_url}}">{{ to_ua }}</a></th>
        </thead>
        <tbody>
        {% for result in kind.list %}
            <tr>
                <td colspan="2" class="test-url">
                    <a href="{% url test-detail result.test_id %}">
                        {{ result.test_label }}
                    </a>
                </td>
            </tr>
            <tr>
                <td class="test-result">
                    <a href="{% url result-detail result.from_id %}"
                       class="result result-{{ result.from_status|lower }}">
                        {{ result.from_status }}
                    </a>
                </td>
                <td class="test-result">
                    <a href="{% url result-detail result.to_id %}"
                       class="result result-{{ result.to_status|lower }}">
                        {{ result.to_status }}
                    </a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endfor %}

{% endif %}

{% endblock %}
